<table id="krepoList" data-options="title:'资源库列表',loadMsg:'数据加载中...',toolbar:'#krepoListToolbar',fit:true,striped:true,
	singleSelect:true,border:false,pagination:true"></table>
<div id="krepoListToolbar" style="padding:5px;">
	资源库名称：<input id="krepName" class="easyui-textbox" style="width:150px">&nbsp;
	资源库类型: <input id="krepType" data-options="valueField:'value',textField:'label',panelHeight:'auto',editable:false">&nbsp;
	<a href="javascript:krepoSearch()" class="easyui-linkbutton" iconCls="icon-search">查询</a>&nbsp;
	<a href="javascript:krepoReset()" class="easyui-linkbutton" iconCls="icon-undo">重置</a>&nbsp;
	<a href="javascript:krepoAddPage()" class="easyui-linkbutton" iconCls="icon-add">新增</a>
</div>
	
<script type="text/javascript" src="cusy/js/repository.js"></script>
<script type="text/javascript">
$(function() {
	$(krepType).combobox({ data: repoTypeData });
	
	// 设置datagrid分页
	var pageNumber = $(krepPageNum).val();
	if (pageNumber) pageNumber = pageNumber.split(',')[2];
	else pageNumber = 1;
	
	// 设置datagrid属性
	$(krepoList).datagrid({
		pageNumber: pageNumber,
		columns: [[
			{field:'repName', title:'资源库名称', halign:'center', width:200},
			{field:'repType', title:'资源库类型', halign:'center', width:80, formatter:function(value, row, index){
				if (value == 'file') return '文件';
				else if (value == 'db') return '数据库';
				else value;
			}},
			{field:'repBasePath', title:'文件资源库路径', halign:'center', width:260},
			{field:'dbHost', title:'数据库主机名或IP地址', halign:'center', width:200},
			{field:'dbPort', title:'端口号', halign:'center', width:65},
			{field:'dbName', title:'数据库名称', halign:'center', width:160},
			{field:'id', title:'操作', halign:'center', width:190, formatter:function(value, row, index){
				return '<a class="krepoEdit" href="javascript:krepoEditPage(\''+value+'\')"><i class="fa fa-edit fa-lg"></i> 编辑</a>'+ 
				'<a class="krepoDb" href="javascript:krepoDbPage(\''+value+'\',\''+row.repName+'\')"><i class="fa fa-database fa-lg"></i> 数据源</a>'+
				'<a class="krepoDel" style="color:red;" href="javascript:krepoDelete(\''+value+'\',\''+row.repName+'\')"><i class="fa fa-trash fa-lg"></i> 删除</a>';
			}}
		]],
		loader: krepoDatagridLoader,
		loadFilter: datagridFilter,
		onClickRow: datagridRowUnselect,
		onLoadSuccess: function(resultData) {
			datagridReqErr(this, resultData, 'repName', 7);
			$(".krepoEdit").linkbutton({ height: 23, plain: true });
			$(".krepoDel").linkbutton({ height: 23, plain: true });
			$(".krepoDb").linkbutton({ height: 23, plain: true });
		}
	});
});
</script>